{% extends 'generic/object_retrieve.html' %}
{% load helpers %}

{% block extra_buttons %}
    {% if perms.extras.change_gitrepository %}
        <form class="form-inline" style="display: inline-block"
              method="post" action="{% url 'extras:gitrepository_dryrun' pk=object.pk %}">
            {% csrf_token %}
            <button type="submit" class="btn btn-info">
                <span class="mdi mdi-book-refresh" aria-hidden="true"></span> Dry-Run
            </button>
        </form>
        <form class="form-inline" style="display: inline-block"
              method="post" action="{% url 'extras:gitrepository_sync' pk=object.pk %}">
            {% csrf_token %}
            <button type="submit" class="btn btn-primary">
                <span class="mdi mdi-source-branch-sync" aria-hidden="true"></span> Sync
            </button>
        </form>
    {% endif %}
{% endblock extra_buttons %}

{% block extra_nav_tabs %}
    <li class="nav-item" role="presentation">
        <a href="{% url 'extras:gitrepository_result' pk=object.pk %}" class="nav-link{% if active_tab == 'result' %} active{% endif %}">Synchronization Status</a>
    </li>
{% endblock extra_nav_tabs %}

{% block content_left_page %}
    <div class="card">
        <div class="card-header">
            <strong>Repository Details</strong>
        </div>
        <table class="table table-hover card-body attr-table">
            <tr>
                <td>Remote URL</td>
                <td>{{ object.remote_url }}</td>
            </tr>
            <tr>
                <td>Branch</td>
                <td>
                    <code>{{ object.branch }}</code>
                    {% if object.current_head %}
                        (checked out locally at commit <code>{{ object.current_head }}</code>)
                    {% else %}
                        (not locally checked out yet)
                    {% endif %}
                </td>
            </tr>
            <tr>
                <td>Secrets Group</td>
                <td>{{ object.secrets_group|hyperlinked_object }}</td>
            </tr>
        </table>
    </div>
{% endblock content_left_page %}

{% block content_right_page %}
    <div class="card">
        <div class="card-header">
            <strong>Provided Data Types</strong>
        </div>
        <table class="table table-hover card-body">
            {% for entry in datasource_contents %}
                <tr>
                    <td>
                        <span style="display: inline-block" class="badge bg-info">
                            <span class="mdi {{ entry.icon }}"></span>
                        </span>
                        {{ entry.name|title }}</td>
                    <td>
                        {% if entry.content_identifier in object.provided_contents %}
                            {{ True | render_boolean }}
                        {% else %}
                            {{ False | render_boolean }}
                        {% endif %}
                    </td>
                </tr>
            {% endfor %}
        </table>
    </div>
{% endblock %}
